package cc.yugu.yhdw.common.protocol.msg02;

import cc.yugu.yhdw.common.protocol.MsgCode;
import cc.yugu.yhdw.common.protocol.msg05.Msg051000010;
import cc.yugu.yhdw.common.tool.netty.TypeOperator;
import io.netty.buffer.ByteBuf;

import java.util.ArrayList;
import java.util.List;

public class Msg021000014 extends Msg021 {

    public List<Box> boxs = new ArrayList<Box>();

    @Override
    public int getMsgCode() {
        return MsgCode.MSG_021000014.getCode();
    }

    @Override
    public void readData(ByteBuf buffer) {
        int size = buffer.readInt();
        for (int i = 0; i < size; i++) {
            Box box = new Box();
            box.read(buffer);
            boxs.add(box);
        }
    }

    public static class Box extends TypeOperator {
        public String boxNum;
        public byte active;

        public void write(ByteBuf buffer) {
            writeString(buffer, boxNum);
            buffer.writeByte(active);
        }

        public void read(ByteBuf buffer) {
            boxNum = readString(buffer);
            active = buffer.readByte();
        }
    }
}
